count = 0

def show_button(mx):
    s = ''
    for i in range(len(mx)):
        rbutton = ' '.join([f'{x}' for x in mx[i]])
        s += rbutton + '\n'
    return s 

# -1表示走过的地方
def method(mx: list, h, i, j):
    global count
    count += 1
    # if i == 1 and j == 1:
        # print('debug')

    # print(f'[local z]{i} {j} [h]={h}')
    # print(show_button(mx))
    if h <= 0:
        return False
    if mx[i][j] == 'T':
        return True 
    
    row = len(mx)
    col = len(mx[0])

    def find(x, y, h):
        # 下一格: (i,j) --> (x,y), 不走走过的格子
        if 0 <= x and x < row and 0 <= y and y < col and (mx[x][y] != -1 and mx[x][y] != 'S'):
            t = mx[x][y]
            if mx[x][y] not in list('ST'):
                h -= int(mx[x][y])
                mx[x][y] = -1
            if method(mx, h, x, y):
                return True
            mx[x][y] = t

    def next_h(x, y, h):
        if not (0 <= x and x < row and 0 <= y and y < col):
            return h - 123456789
        if mx[x][y] in list('ST'):
            return h
        try:
            return h - int(mx[x][y])
        except:
            print(f'[error]{mx[x][y]}')
            return 0

    steps = [(i-1, j), (i, j-1), (i, j+1), (i+1, j)]
    for step in steps:
        # step = step[0]
        if find(step[0], step[1], h):
            return True

    return False


def one():
    global count
    count = 0

    row, col, h = [int(x) for x in input().split(' ')]
    mx = []
    for _ in range(row):
        s = list(input())
        mx.append(s)
    
    # 定位起点坐标
    for i in range(len(mx)):
        for j in range(len(mx[0])):
            if mx[i][j] == 'S':
                # print(f'[start]{i} {j} [h]={h}')
                r =  'Yes' if method(mx, h, i, j) else 'No'
                # print(f'[count]{count}')
                return r


if __name__ == '__main__':
    n = int(input())
    for i in range(n):
        r = one()
        print(r)
    